<%@page import="com.gopay.remote.solution.vo.PayChannelDtlInfo"%>
<%@page import="com.gopay.common.constants.trans.PayChannel"%>
<%@page import="com.gopay.cashier.domain.bean.PayChannelDtlBean"%>
<%@page import="com.gopay.common.constants.trans.PayChannelType"%>
<%@page import="com.gopay.cashier.domain.bean.PayChannelWayBean"%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="../../common/init.jsp"%>
<%@ page import="java.util.List"%>

<script type="text/javascript" src="${ctx}/static/00100/javascripts/gopay/payOrder.js"></script>
<%--<script type="text/javascript" src="${ctx}/static/00100/javascripts/gopay/gopayChannel.js"></script>--%>
<script type="text/javascript" src="${ctx}/static/00100/javascripts/gopay/bankPayChannel.js"></script>
<script type="text/javascript" src="${ROOT}/static/js/gopay/paymentLimit.js"></script>
<%
    int moreBanks = 15;
    PayChannelWayBean pw=(PayChannelWayBean)request.getAttribute("payWayBean");
    PayChannelDtlBean pcb = pw.getPayChannelDtl(PayChannelType.OUTSTLM_PAY.value);
    List<PayChannelDtlInfo> personBanks = pcb.getBankCodes().get(PayChannel._01.value);
    List<PayChannelDtlInfo> corpBanks =  pcb.getBankCodes().get(PayChannel._51.value);
    int pbankNums = personBanks==null?0:personBanks.size();
    int ebankNums = corpBanks==null?0:corpBanks.size();
%>
<c:set var="pbankNum" value="<%=pbankNums %>"/>
<c:set var="ebankNum" value="<%=ebankNums %>"/>

<script type="text/javascript">
    var pbankNum = '<%=pbankNums %>';
    var ebankNum = '<%=ebankNums %>';
</script>

<shiro:authenticated>
    <form name="bankPayForm" id="bankPayForm" action="${ctx}/sec/00100/pay/confirm.shtml?orderKey=<%=request.getParameter("orderKey")%>&orderId=<%=request.getParameter("orderId")%>" method="post">
</shiro:authenticated>
<shiro:notAuthenticated>
    <form name="bankPayForm" id="bankPayForm" action="${ctx}/pay/bpc.shtml?orderKey=<%=request.getParameter("orderKey")%>&orderId=<%=request.getParameter("orderId")%>" method="post">
</shiro:notAuthenticated>
    <div class="tabscon posiRelative" id="bankPayTab" style="display: none;">
        <table class="table-tml">
            <tbody>
            <tr>
                <th>选择银行类型：</th>
                <td>
                    <c:if test='${(pbankNum gt 0) }'>
                        <input type="radio" id="personalBank" name="bankPayChannel" value="01" class="marginRight10 pay-radio"><label for="personalBank" class="marginRight40 font16 color-333"  style="cursor: pointer;">个人网上银行支付</label>
                    </c:if>
                    <c:if test="${ebankNum gt 0}">
                        <input type="radio"  id="corpBank" name="bankPayChannel"  value="51" class="verticalMiddle marginRight10 pay-radio"><label for="corpBank" class="font16 color-333" style="cursor: pointer;">企业网上银行支付</label>
                    </c:if>
                </td>
            </tr>
            <tr>
                <th class="verticalTop">付款银行：</th>
                <td style="padding-bottom: 0px;">
                    <c:if test='${(pbankNum gt 0) }'>
                    <div class="bank-list " id="personalBankList">
                        <div class="fix">
                        <%
                            //输出个人银行的图标
                            for(int i=0; i<pbankNums&&i<moreBanks; i++){
                                PayChannelDtlInfo info = personBanks.get(i);
                                String bc = info.getOutStlmId();
                                out.print("<div class='items'>\n");
                                out.print("<label for='i_b_c_"+i+"' onclick=bankSel('i_b_c_"+i+"',this);>\n");
                                out.print("<img disabled='disabled' height='40' border='0' src='"+request.getContextPath()+"/BankIcon/"+bc+".jpeg'  alt='"+bc+"' style='cursor:pointer'/>\n");
                                out.print("</label>\n");
                                out.print("<input type='radio' id='i_b_c_"+i+"' name='personalPayBankCode' value='"+bc+"' onclick=bankSel(\'i_b_c_"+i+"\',this);>\n");
                                out.print("</div>\n");
                            }
                        %>
                        </div>
                        <% if(pbankNums>moreBanks){ %>
                        <a class="underline-none font12 color-333" href="javascript:void(0);" onclick="showAllBanks('01');">查看更多银行&gt;&gt;</a>
                        <%  } %>
                    </div>

                    </c:if>
                    <c:if test='${ebankNum gt 0 }'>
                    <div class="bank-list" id="corpBankList">
                        <div class="fix">
                        <%
                            //输出企业银行的图标
                            for(int i=0; i<ebankNums && i<moreBanks; i++){
                                PayChannelDtlInfo info = corpBanks.get(i);
                                String bc = info.getOutStlmId();
                                out.print("<div class='items'>\n");
                                out.print("<label for='e_b_c_"+i+"' onclick=bankSel('e_b_c_"+i+"',this);>\n");
                                out.print("<img disabled='disabled' height='40' border='0' src='"+request.getContextPath()+"/BankIcon/"+bc+".jpeg'  alt='"+bc+"' style='cursor:pointer'/>\n");
                                out.print("</label>\n");
                                out.print("<input type='radio' id='e_b_c_"+i+"' name='corpPayBankCode' value='"+bc+"' onclick=bankSel(\'e_b_c_"+i+"\',this);>\n");
                                out.print("</div>\n");
                            }
                        %>
                        </div>
                        <% if(ebankNums>moreBanks){ %>
                        <a class="underline-none font12 color-333" href="javascript:void(0);" onclick="showAllBanks('51');">查看更多银行&gt;&gt;</a>
                        <%  } %>
                    </div>

                    </c:if>
                </td>
            </tr>
            <shiro:notAuthenticated>
            <tr>
                <th></th>
                <td>
                    <button type="button" id="bankPayBtn1"  class="btn-2 marginTop20" onclick='bankPaySubmit("bankPayBtn1");'>下一步</button>
                </td>
            </tr>
            </shiro:notAuthenticated>
            </tbody>
        </table>
        <div class="pos_r" style=" padding-left:25px;margin-left:146px;color:#666; margin-top:-40px;"><i class="icon-tipsye pos_a" style="width:27px; height:24px; background:url(${ctx}/static/00100/images/tips-yellow.png) 0 center no-repeat; left:0; top:50%; margin-top:-13px;"></i>温馨提示：为了保证您成功支付，建议使用IE7.0以上版本浏览器</div>
        <p style="height:40px;"></p>
        <input type="hidden" name="payChannel" id="payChannel" value="01"/>
        <input type="hidden" name="orderId" id="orderId" value="<%=request.getParameter("orderId")%>"/>
        <input type="hidden" name="formhash" id="formhash" value="${formhash }"/>
        <input type="hidden" name="gopayUser" id="gopayUser" value=""/>
        <input type="hidden" name="pageFrom" value="order"/>
        <input type="hidden" name="gopayAcctId" id="gopayAcctId" value="${gopayAcctId }"/>
        <input type="hidden" name="payWay" id="payWay" value="F"/>
        <input type="hidden" name="payBankCodeAll" id="payBankCodeAll"/>
        <input type="hidden" name="orderKey" id="orderKey" value="<%=request.getParameter("orderKey")%>"/>

    </div>

    <div id="allPersonBanksDialog" style="display:none" class="personDialog">
        <div class="bank-list-2 fix">
            <%
                //输出个人银行的图标
                for(int i=0; i<pbankNums; i++){
                    PayChannelDtlInfo info = personBanks.get(i);
                    String bc = info.getOutStlmId();
                    out.print("<div class='items'>\n");
                    out.print("<label for='a_i_b_c_"+i+"' onclick=bankSel('a_i_b_c_"+i+"',this);>\n");
                    out.print("<img disabled='disabled' height='40' border='0' src='"+request.getContextPath()+"/BankIcon/"+bc+".jpeg'  alt='"+bc+"' style='cursor:pointer'/>\n");
                    out.print("</label>\n");
                    out.print("<input type='radio' id='a_i_b_c_"+i+"' name='personalPayBankCodeAll' value='"+bc+"'  onclick=bankSel(\'a_i_b_c_"+i+"\',this);>\n");
                    out.print("</div>\n");
                }
            %>
        </div>
        <button type="button"  id="bankPayBtn3" class="btn-2 marginLeft303" onclick='bankPaySubmit("bankPayBtn3");'>下一步</button>
    </div>

    <div id="allCorpBanksDialog" style="display:none">
        <div class="bank-list-2 fix">
            <%
                //输出企业银行的图标
                for(int i=0; i<ebankNums; i++){
                    PayChannelDtlInfo info = corpBanks.get(i);
                    String bc = info.getOutStlmId();
                    out.print("<div class='items'>\n");
                    out.print("<label for='a_e_b_c_"+i+"' onclick=bankSel('a_e_b_c_"+i+"',this);>\n");
                    out.print("<img disabled='disabled' height='40' border='0' src='"+request.getContextPath()+"/BankIcon/"+bc+".jpeg'  alt='"+bc+"' style='cursor:pointer'/>\n");
                    out.print("</label>\n");
                    out.print("<input type='radio' id='a_e_b_c_"+i+"' name='corpPayBankCodeAll' value='"+bc+"'  onclick=bankSel(\'a_e_b_c_"+i+"\',this);>\n");
                    out.print("</div>\n");
                }
            %>
        </div>
        <button type="button" id="bankPayBtn4" class="btn-2 marginLeft303" onclick='bankPaySubmit("bankPayBtn4");'>下一步</button>
    </div>
</form>